import 'package:flutter/material.dart';

import '../example/index.dart';
import '../example/routes.dart';
import '../pages/about/about.dart';
import '../pages/home/home.dart';

Map routes = {
  '/': (context) => const HomePage(),
  '/about': (context) => const AboutPage(),
  '/example': (context) => const ExamplePage(),
  ...exampleRoutes
};


var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Object? arguments = settings.arguments;
  final Function? pageBuilder = routes[name];

  if (pageBuilder == null) return null;
  final Route route = MaterialPageRoute(
    builder: (context) => (arguments != null?pageBuilder(context,arguments):pageBuilder(context))
  );

  return route;
};
